#ifndef __GPS_H_
#define __GPS_H_

#include "stdint.h"
#include "usart5.h"

#define UART5_GPS_BUFF_SIZE 128

extern unsigned char GPS_GGA_ON[]      ;
extern unsigned char GPS_SAVE[]        ;
// GPS命令                             
extern unsigned char GGA_OFF[]         ;
extern unsigned char GGA_ON[]          ;
extern unsigned char GLL_OFF[]         ;
extern unsigned char GLL_ON[]          ;
extern unsigned char GSA_OFF[]         ;
extern unsigned char GSA_ON[]          ;
extern unsigned char GSV_OFF[]         ;
extern unsigned char GSV_ON[]          ;
extern unsigned char RMC_OFF[]         ;
extern unsigned char RMC_ON[]          ;
extern unsigned char VTG_OFF[]         ;
extern unsigned char VTG_ON[]          ;
extern unsigned char ZDA_OFF[]         ;
extern unsigned char ZDA_ON[]          ;
extern unsigned char GST_OFF[]         ;
extern unsigned char GST_ON[]          ;
extern unsigned char GNTXT_OFF[]       ;
extern unsigned char GNTXT_ON[]        ;
extern unsigned char GPS_RECOVER[]     ;
//extern unsigned char GPS_SAVE[]        ;
extern unsigned char GPS_115200[]      ;
extern unsigned char GPS_L1[]          ;
extern unsigned char GPS_L1_L5[]       ;
extern unsigned char GPS_BD[]          ;
extern unsigned char GPS_GPS[]         ;



//GPS NMEA-0183协议重要参数结构体定义 
//卫星信息
typedef struct  
{										    
 	uint8_t num;		//卫星编号
	uint8_t eledeg;	//卫星仰角
	uint16_t azideg;	//卫星方位角
	uint8_t sn;		//信噪比		   
}nmea_satellitemsg; 
//北斗 NMEA-0183协议重要参数结构体定义 
//卫星信息
typedef struct  
{	
 	uint8_t beidou_num;		//卫星编号
	uint8_t beidou_eledeg;	//卫星仰角
	uint16_t beidou_azideg;	//卫星方位角
	uint8_t beidou_sn;		//信噪比		   
}beidou_nmea_satellitemsg; 

//UTC时间信息
typedef struct  
{										    
 	uint16_t year;	//年份
	uint8_t month;	//月份
	uint8_t date;	//日期
	uint8_t hour; 	//小时
	uint8_t min; 	//分钟
	uint8_t sec; 	//秒钟
}nmea_utc_time;   	   
//NMEA 0183 协议解析后数据存放结构体
typedef struct  
{										    
 	uint8_t svnum;					//可见GPS卫星数
	uint8_t beidou_svnum;			//可见GPS卫星数
	nmea_satellitemsg slmsg[12];		//最多12颗GPS卫星
	beidou_nmea_satellitemsg beidou_slmsg[12];		//暂且算最多12颗北斗卫星
	nmea_utc_time utc;			//UTC时间
	uint32_t latitude;				//纬度 分扩大100000倍,实际要除以100000
	uint8_t nshemi;					//北纬/南纬,N:北纬;S:南纬				  
	uint32_t longitude;			    //经度 分扩大100000倍,实际要除以100000
	uint8_t ewhemi;					//东经/西经,E:东经;W:西经
	uint8_t gpssta;					//GPS状态:0,未定位;1,非差分定位;2,差分定位;6,正在估算.				  
 	uint8_t posslnum;				//用于定位的GPS卫星数,0~12.
 	uint8_t possl[12];				//用于定位的卫星编号
	uint8_t fixmode;					//定位类型:1,没有定位;2,2D定位;3,3D定位
	uint16_t pdop;					//位置精度因子 0~500,对应实际值0~50.0
	uint16_t hdop;					//水平精度因子 0~500,对应实际值0~50.0
	uint16_t vdop;					//垂直精度因子 0~500,对应实际值0~50.0 

	int altitude;			 	//海拔高度,放大了10倍,实际除以10.单位:0.1m	 
	uint16_t speed;					//地面速率,放大了1000倍,实际除以10.单位:0.001公里/小时	 
}nmea_msg;

extern nmea_msg GPS_message;
 
int NMEA_Str2num(uint8_t *buf,uint8_t*dx);
void NMEA_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_GPGSV_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_BDGSV_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_GNGGA_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_GNGSA_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_GNGSA_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_GNRMC_Analysis(nmea_msg *gpsx,uint8_t *buf);
void NMEA_GNVTG_Analysis(nmea_msg *gpsx,uint8_t *buf);
void Gps_Analyse(nmea_msg *gpsx,uint8_t *buf,uint16_t buf_size);
void My_Reset(uint8_t *buf, uint16_t buf_size);

void SmallToBig(unsigned char *src);
void  DecToHexToAscii(uint32_t data1, int data2,unsigned char *strArray, uint8_t Flag);
void AutoCompletion(unsigned char *OsdModule_buff, unsigned char MustLen, unsigned char FillDate);
unsigned char Convert_DegreesMinutesSeconds(uint32_t SrcDate, unsigned char *Decbuf);
void GPS_Refresh_Set(void);


#endif // !__GPS_H_
